import {request} from '@/base/Request';
import {Firmware} from '@/base/model/Firmware'
import qs from 'qs'

export function postFirmware(params: {
  describe: string,
  extName: string,
  modelId: number,
  sortId: number,
  url: string,
  versions: number,
  issueStatus: string
}) {
  return request.post(Firmware, '/api/firmware', qs.stringify(params))
}

export function getFirmware(params: {
  pageIndex: number,
  pageSize: number,
  sortDirection: string,
  accountName: string,
  versions: number,
  issueStatus: string,
  modelId: number
}) {
  return request.getPage(Firmware, '/api/firmware', {params})
}

export function firmwareVersions(params?: { modelId: number }) {
  return request.getArray(Number, '/api/firmware/version', {params})
}

export function getFirmwareId(
  id: number
) {
  return request.get(Firmware, `/api/firmware/${id}`)
}

export function PutFirmwareId(params: {
  describe: string,
  extName: string,
  id: number,
  issueStatus: string,
  modelId: number,
  sortId: number,
  url: string
}) {
  return request.put(Firmware, `/api/firmware/${params.id}`, qs.stringify(params))
}

export function deleteFirmwareId(
  id: number
) {
  return request.delete(`/api/firmware/${id}`)
}
